package com.halflife.comeElectricity.util;

import com.spatial4j.core.context.SpatialContext;
import com.spatial4j.core.distance.DistanceUtils;
import com.spatial4j.core.shape.Rectangle;

/**
 * Created by zhaoyf on 2018/2/14.
 */
public class GeoUtil {
    public static Double[] getRange(Double longitude,Double latitude,Integer distance){
        SpatialContext geo = SpatialContext.GEO;
        Rectangle rectangle = geo.getDistCalc().calcBoxByDistFromPt(
                geo.makePoint(longitude, latitude), distance * DistanceUtils.KM_TO_DEG, geo, null);
        return new Double[]{rectangle.getMinX(),rectangle.getMaxX(),rectangle.getMinY() , rectangle.getMaxY()};
    }
}
